<%--
  Created by IntelliJ IDEA.
  User: hongcy
  Date: 16-3-20
  Time: 下午9:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ include file="/include/taglib.jsp" %>
<div style="padding:20px 0px;">
    <form method="post" action="${ctx}/mulanweb/seller/content/updateChartered" id="ff">
        <table cellspacing="5" style="margin: 0 auto">
            <tr>
                <td><span class="form-language" id="q1">Service Date</span>:</td>
                <td><select id="server-date-select" style="width: 260px;">
                </select>
                    <input type="hidden" name="serverTime" id="serverTime" value="1"/>
                </td>
            </tr>
            <tr>
                <td><span class="form-language" id="q2">Service Time</span>:</td>
                <td><input id="start-server-time-select-h" style="width: 50px;"/>:
                    <input id="start-server-time-select-m" style="width: 50px;"/>
                    -
                    <input id="end-server-time-select-h" style="width: 50px;"/>:
                    <input id="end-server-time-select-m" style="width: 50px;"/>
                    <input type="hidden" name="startTime" id="startTime"/>
                    <input type="hidden" name="endTime" id="endTime"/>
                    <input type="hidden" name="weekWork" id="weekWork" />
                    <input type="hidden" name="targetId" value="${param.targetId}"/>
                </td>
            </tr>
        </table>
    </form>
    <input type="hidden" id="oldWeekWork" value="${param.weekWork}"/>
    <input type="hidden" id="oldStartTime" value="${param.startTime}"/>
    <input type="hidden" id="oldEndTime" value="${param.endTime}"/>
</div>
<script type="text/javascript">

    var english = {
        q1:'Service Date',
        q2:'Service Time',
        x1:'Monday',
        x2:'Tuesday',
        x3:'Wednesday',
        x4:'Thursday',
        x5:'Friday',
        x6:'Saturday',
        x7:'Sunday',
    }

    var chinese = {
        q1:'服务日期',
        q2:'服务时间',
        x1:'星期一',
        x2:'星期二',
        x3:'星期三',
        x4:'星期四',
        x5:'星期五',
        x6:'星期六',
        x7:'星期日',
    }

    $(function () {
        var language  ;
        if('${param.language}' == '1'){
            language=chinese;
            $("#q1").html(language.q1);
            $("#q2").html(language.q2);
        }else{
            language=english;
        }

        var hour = [] ;
        for(var i = 0 ; i<24 ; i++){
            hour.push({'value':i,text:i+""});
        }
        var minute = [] ;
        for(var i = 0 ; i<60 ; i++){
            minute.push({'value':i,text:i+""});
        }
        $("#start-server-time-select-h,#end-server-time-select-h").combobox({
            required:true,
            valueField:'value',
            textField:'text',
            editable:false,
            data:hour,
            onChange:checkup
        });
        $("#start-server-time-select-m,#end-server-time-select-m").combobox({
            required:true,
            valueField:'value',
            textField:'text',
            editable:false,
            data:minute,
            onChange:checkup
        });
        function checkup(newV,oldV){
            var startHouse = $("#start-server-time-select-h").combo("getValue");
            var endHouse = $("#end-server-time-select-h").combo("getValue");
            var startMinute= $("#start-server-time-select-m").combo("getValue");
            var endMinute = $("#end-server-time-select-m").combo("getValue");
            if(startHouse && startMinute){
                $("#startTime").val(startHouse+":"+startMinute+":00");
            }else if(startHouse){
                $("#startTime").val(startHouse+":00:00");
            }else if(startMinute){
                $("#startTime").val("00:"+startMinute+":00");
            }
            if(endHouse && endMinute){
                $("#endTime").val(endHouse+":"+endMinute+":00");
            }else if(endHouse){
                $("#endTime").val(endHouse+":00:00");
            }else if(endMinute){
                $("#endTime").val("00:"+endMinute+":00");
            }

            /*if(startHouse == endHouse){
                if(startMinute>endMinute){
                    Constant.showMessage("您的结束时间大于开始时间，时间无效")
                }
            }else if(startHouse > endHouse){
                Constant.showMessage("您的结束时间大于开始时间，时间无效")
            }*/
        }
        $("#start-server-time-select-h").combobox('setValue',"${param.startTime}".split(":")[0]);
        $("#end-server-time-select-h").combobox('setValue',"${param.endTime}".split(":")[0]);
        $("#start-server-time-select-m").combobox('setValue',"${param.startTime}".split(":")[1]);
        $("#end-server-time-select-m").combobox('setValue',"${param.endTime}".split(":")[1]);
        $("#server-date-select").combobox({
            multiple:true,
            valueField:'value',
            textField:'text',
            data:[{
                text:language.x1,
                value:1
            },{
                text:language.x2,
                value:2
            },{
                text:language.x3,
                value:3
            },{
                text:language.x4,
                value:4
            },{
                text:language.x5,
                value:5
            },{
                text:language.x6,
                value:6
            },{
                text:language.x7,
                value:7
            },],
            onChange:function(newV,oldV){
                $("#weekWork").val(newV);
            }

        });
        $("#server-date-select").combobox("setValues",$("#oldWeekWork").val().split(","));
    })
</script>
